package APong.Entity;

import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.geom.Circle;
import org.newdawn.slick.geom.Shape;
import org.newdawn.slick.state.StateBasedGame;

import APong.World.World;

public class Ball extends Entity {

	public Ball(World world, float x, float y) {
		super(world, x, y,20,20);
		this.setKeepVelocity(true);
	}

	@Override
	protected void renderEntity(GameContainer gc, Graphics g) {
		this.fillCollisionShape(g);
	;
	}

	@Override
	protected void updateEntity(GameContainer gc, StateBasedGame sbg) {
		
		
	}
	
	@Override
	public Shape getCollisionShape(float xa, float ya) {
		return new Circle((x + (world.getDeltaTime() * xa)), (y + (world.getDeltaTime() * ya)), width / 2);
	}

	@Override
	public boolean isSolid(Entity e) {
		return true;
	}

	@Override
	public void collide(Entity e) {
		if(e instanceof Wall){
			Wall wall = (Wall)e;
			if(wall.isHorizontal){
			this.bounceY();
			}else
			if(!wall.isHorizontal){
				this.bounceX();
			}
		}else
		if(e instanceof Paddle){
			if(this.x <= e.x + e.width){
				this.bounceY();
				this.bounceX();
			}else{
			this.bounceX();
			}
		}
		
	}

}
